package com.treasure.mall.zbqmallapi.vo.user;

import com.treasure.mall.biz.entity.user.UserAddressPO;
import com.treasure.mall.biz.vo.BaseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author allan
 * @version 1.0.0
 * @date 2020/7/6
 */
@Data
@ApiModel("用户收获地址")
@NoArgsConstructor
public class UserAddressVO implements BaseVO {
    private static final long serialVersionUID = 4499640142448480011L;

    @ApiModelProperty("地址id")
    private Long id;
    @ApiModelProperty("所属用户")
    private Long userId;
    /**
     * 收货人
     */
    @ApiModelProperty("收货人")
    private String userName;
    /**
     * 收货人手机
     */
    @ApiModelProperty("收货人手机")
    private String telNumber;
    /**
     * 省
     */
    private String provinceName;
    /**
     * 省代码
     */
    private String provinceCode;
    /**
     * 市
     */
    private String cityName;
    /**
     * 市代码
     */
    private String cityCode;
    /**
     * 区
     */
    private String countyName;
    /**
     * 区代码
     */
    private String districtCode;
    /**
     * 详细地址
     */
    private String detailInfo;
    /**
     * 收货地址国家码
     */
    @ApiModelProperty(value = "收货地址国家码", required = false)
    private String nationalCode;
    /**
     * 邮编
     */
    @ApiModelProperty(value = "邮编")
    private String postalCode;
    @ApiModelProperty(value = "是否默认")
    private boolean defAddr;

    public UserAddressVO(UserAddressPO po) {
        this.id = po.getId();
        this.userId = po.getUserId();
        this.userName = po.getReceivingInfo().getUserName();
        this.telNumber = po.getReceivingInfo().getTelNumber();
        this.provinceName = po.getReceivingInfo().getProvinceName();
        this.provinceCode = po.getReceivingInfo().getProvinceCode();
        this.cityCode = po.getReceivingInfo().getCityCode();
        this.cityName = po.getReceivingInfo().getCityName();
        this.countyName = po.getReceivingInfo().getCountyName();
        this.districtCode = po.getReceivingInfo().getDistrictCode();
        this.detailInfo = po.getReceivingInfo().getDetailInfo();
        this.nationalCode = po.getReceivingInfo().getNationalCode();
        this.postalCode = po.getReceivingInfo().getPostalCode();
        this.defAddr = po.isDefAddr();
    }
}
